#pragma once
#include<windows.h>
#include<winioctl.h>
#include <ntsecapi.h>
#define DEVICE_LINK_NAME   "\\??\\NDIS"
#define READPROCESSMEMORY CTL_CODE(FILE_DEVICE_UNKNOWN, 0x3838438, METHOD_BUFFERED, FILE_ANY_ACCESS)

typedef struct FakeIoInfo
{
	ULONG Flage;
	ULONG Code;
	int   Pid;
}__FakeIoInfo, *PFakeIoInfo;

#define PAGE_TABLE_SIZE  0X1000
#define MEMORY_PAGE_MAX 0x1000
#define GET_PTML4_ERROR  ((NTSTATUS)0x000000001)
#define GET_PDPT_ERROR   ((NTSTATUS)0x000000002)
#define GET_PDT_ERROR    ((NTSTATUS)0x000000003)
#define GET_PT_ERROR     ((NTSTATUS)0x000000004)


typedef union {
	ULONG_PTR ulVirtualAddress;
	struct
	{
		ULONG64 offset : 12;
		ULONG64 PT : 9;
		ULONG64 PDT : 9;
		ULONG64 PDPT : 9;
		ULONG64 PLM4 : 9;
		ULONG64 Extend : 16;
	}stVirtualAddress;

}VIRTUAL_ADDRESS, *PVIRTUAL_ADDRESS;


class DriverIo
{
public:
	DriverIo();
	~DriverIo();
 
public :
	BOOLEAN DriverInitialization();
	ULONG64 R3Initialization();

public:
	ULONG64 SetProcess(DWORD Pid);
	BOOLEAN ReadProcess_Me(ULONG_PTR Addr, ULONG_PTR Size, PVOID Buffer);
	ULONG64 GetProcessStartAddr();
private:
	HANDLE m_Hande = NULL;
	ULONG64 m_StartAddr = 0;
	ULONG64 m_Cr3 = 0;
};

